#ifndef __UTILS_H__
#define __UTILS_H__



#include<stdio.h>
#include<string.h>
#include<vector>
#include<ext/hash_map>


#include "define.h"

#define  ISDIGIT(x)   isdigit(x)  //是不是数字;


/**
 * @brief 命令行参数结构体;
 */
struct CmdFunctionSet 
{
	int index;
	int (* registerFunc)(void *arg);
	bool argFlag;
};




/**
 * @brief 工具辅助类;
 */
class Utils
{
	public:
		int registerCmdFunctionInit();
		static int isIpv4(const char * ipaddr);
		static int isPort(char * portaddr,std::vector<char *>  &port);
		static int pathIsReadable(const char * path);
		static int setFdNonblock(int fd);
		static int FormatCmd(char *pCmd, char *pBuf);
		static int displaySystemStatus(void *arg);
		static int setPthreadStackSize(void *arg);
		static int setPthreadPolicy(void *arg);
		static int displaySystemLog(void *arg);
		static int setSystemLogLevel(void *arg);
		static int displayThreadIdStatus(void *arg);
		static int restart(void *arg);
		static int quit(void *arg);
		static int help(void *arg);
		__gnu_cxx::hash_map<int , struct CmdFunctionSet> & getCmdHashOpt(){ return  cmdHash; }
	public:
#define MAX_CMD_SET_SIZE 100
		static struct CmdFunctionSet CmdSet[MAX_CMD_SET_SIZE];
	private:
		__gnu_cxx::hash_map<int, struct CmdFunctionSet> cmdHash;

};


#endif

